<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    let str = '1234567'
    function toMoneyStr(str) {

        // console.log(str);
        let str2 = ''
        let count = 0
        for (let i = str.length - 1; i >= 0; i--) {
            //    console.log(str[i]);
            str2 = str[i] + str2
            // console.log(str2);
            count++
            // console.log(count);
            if (count / 3 == 0 && i != 0) {
                str2 = "," + str[i] + str2
                console.log(str2);
            }
        }
        return str2
    }
    let x = toMoneyStr(str)
    // console.log(x);
</script>